Skip to content

refactor(daemon): trim expired-lease admission code - #5164

Merged
thymikee merged 3 commits into
mainfrom
refactor/lease-cleanup-trim
Nov 28, 2026
Merged

thymikee merged 3 commits into
mainfrom
refactor/lease-cleanup-trim

Conversation

@thymikee

@thymikee thymikee commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Trims daemon code added by #5151, with no intended behaviour change. cleanupExpiredLeasedSession now classifies its request once. bindOutsideRequestLocks stays: inlining it put createRequestExecutionScope over the Fallow cyclomatic threshold.

holdsSessionLocks stays because its invariant is false. resolveRequestExecutionLockPlan reads the session store before runLocked takes any lock. A close planned with no session omits the session's device lock unless its flags selected that device. An open ahead of it can then publish the session, and without the check close tears it down while another request holds the device.

normalizeLeaseId(leaseId) ?? leaseId stays: its caller passes the raw request id.

Value

  • Production lines: +19 / −23 (net −4).
  • Request predicates in lease-lifecycle.ts: 4 → 2.
  • isBoundedCompositeRequest call sites there: 2 → 1.

Validation

At b208b5b (bd71651 restores the helper only):

  • lease-lifecycle.test.ts and request-execution-scope-lease-expiry.test.ts, unchanged: 29 passed. OXC formatted.

Item 2 evidence, on the base commit:

  • With the check removed, the existing test a close that finds its session busy ends it once that request finishes fails.
  • A temporary, uncommitted test through runLocked (session published after planning, device held) passed with the check and failed without it.

No gates run locally; CI pending. No independent review; the author re-read the diff.

Security

Typed refusals, dispatched: 'no', assertLeaseActive and redaction are unchanged. The lease end is still bound before locks are taken.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.68 MB 6.68 MB +54 B
Package (unpacked) 6.68 MB 6.68 MB +54 B
Package (download) 2.04 MB 2.04 MB +25 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.7 ms 22.6 ms +0.9 ms
CLI --help 48.3 ms 49.1 ms +0.8 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

View guided diff | Turn on auto-fix | Re-trigger cubic

Inlining it added a branch that put createRequestExecutionScope over the
Fallow cyclomatic threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This is ready at bd71651, with no code changes required. CI checks pass, with Proof skipped. Not verified here: local test, Fallow and format runs, the temporary runLocked test, and device or live daemon behavior; test outcomes rely on CI and the equivalence on code tracing. Not blocking: the new comment on holdsSessionLocks could say it can be false for a close planned before its session existed, since a close whose device flags select that device plans both the session and device locks, so take it or leave it.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of b1fcf14

Since the review of bd71651: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (fc50f31d3870).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 28, 2026
@thymikee

Copy link
Copy Markdown
Member Author

No code problems were found in the changes at b1fcf14 since the earlier review at bd71651. They only touch comments and fix the one remaining note on comment wording; the previously reviewed code was not reviewed again.

All 21 checks pass at this commit. Nothing from this review needs to change before merge. Not verified here: local tests and live daemon or device runs.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 28, 2026
@thymikee
thymikee merged commit e52cd29 into main Nov 28, 2026
21 checks passed
@thymikee
thymikee deleted the refactor/lease-cleanup-trim branch November 28, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant